package conditional;

import data.DataElement;
import data.DataElement.DataElementType;

public class SwitchConditional extends Conditional {

	private String switchName;
	private boolean triggerState;

	@Override
	public DataElement createConditionalElement() {
		DataElement de = new DataElement("Conditional",
				DataElementType.COMPLEX, null);
		de.addChildElement(new DataElement("Conditional Type",
				DataElementType.STRING, "Switch"));
		DataElement lines = new DataElement("Conditional Lines",
				DataElementType.COMPLEX, null);
		lines.addChildElement(new DataElement("Switch Name",
				DataElementType.STRING, switchName));
		lines.addChildElement(new DataElement("Trigger State",
				DataElementType.BOOL, triggerState));
		de.addChildElement(lines);
		return de;
	}

	@Override
	public void buildFromLinesElement(DataElement lines) {
		switchName = (String) lines.getChildElementOfName("Switch Name")
				.getValue();
		triggerState = (Boolean) lines.getChildElementOfName("Trigger State")
				.getValue();
	}

}
